<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/include/page.jsp" %>
<jsp:useBean id="admin" class="com.carlinfo.userscenter.users.pojo.AAdmins"></jsp:useBean>
<!DOCTYPE HTML>
<html>
	<head>
		<title>朝代更新</title>
		<%@ include file="/common/include/title.jsp" %>
		<script type="text/javascript" src="${rootPath }/common/resource/H-ui.admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
		<script type="text/javascript" src="${rootPath }/common/resource/H-ui.admin/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
		<script type="text/javascript" src="${rootPath }/common/resource/H-ui.admin/lib/jquery.validation/1.14.0/messages_zh.js"></script> 
		<meta name="keywords" content="H-ui.admin v3.1,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
		<meta name="description" content="H-ui.admin v3.1，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
	</head>
	<body>
	<article class="page-container">					
	<form class="form form-horizontal" id="form-admin-add" enctype="multipart/form-data">
		<!-- 将id传过去 -->
		<input type="hidden" name="id" value="${requestScope.admins.id}">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>邮箱：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="${requestScope.admins.email }" placeholder="" id="email" name="email">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>真实姓名：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" autocomplete="off" value="${requestScope.admins.trueName }" placeholder="" id="trueName" name="trueName">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>qq：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" autocomplete="off" value="${requestScope.admins.qq }" placeholder="" id="qq" name="qq">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" autocomplete="off" value="${requestScope.admins.phone }" placeholder="" id="phone" name="phone">
			</div>
		</div>
		<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span
						class="c-red">*</span>性别：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<label for="sex0">
							<!-- 目前:状态应该是数据库里面选中的效果 -->
							<input type="radio" value="0" placeholder=""
								${'0' == requestScope.admins.sex ? 'checked' : '' }
								id="sex0" name="sex">未知
						</label>
						<label for="sex1">
							<!-- 目前:状态应该是数据库里面选中的效果 -->
							<input type="radio" value="1" placeholder=""
								${'1' == requestScope.admins.sex ? 'checked' : '' }
								id="sex0" name="sex">男
						</label>
						<label for="sex0">
							<!-- 目前:状态应该是数据库里面选中的效果 -->
							<input type="radio" value="2" placeholder=""
								${'2' == requestScope.admins.sex ? 'checked' : '' }
								id="sex2" name="sex">女
						</label>
					</div>
				</div>
		<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span
						class="c-red">*</span>状态：</label>
				<div class="formControls col-xs-8 col-sm-9">
						<label for="status0">
							<!-- 目前:状态应该是数据库里面选中的效果 -->
							<input type="radio" value="0" placeholder=""
							${'0' == requestScope.admins.status ? 'checked' : '' }
							id="status0" name="status">禁用
					</label>
					<label for="status1">
							<!-- 目前:状态应该是数据库里面选中的效果 -->
							<input type="radio" value="1" placeholder=""
							${'1' == requestScope.admins.status ? 'checked' : '' }
							id="status1" name="status">启用
					</label>
				</div>
		</div>
		<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span
						class="c-red">*</span>头像：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="file" class="input-text" value="${requestScope.admins.phone }" placeholder=""
								id="file" name="file">
					</div>
		</div>
		<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span
						class="c-red">*</span>原头像：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<img alt="加载失败" src="${rootPath }/${requestScope.admins.photoPath}" width="100" height="100" style="border-radius: 50px 50px ">
					</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
	</article>	
	<script type="text/javascript">
	$(function(){
		$('.skin-minimal input').iCheck({
			checkboxClass: 'icheckbox-blue',
			radioClass: 'iradio-blue',
			increaseArea: '20%'
		});
		
		$("#form-admin-add").validate({
			rules:{
				adminName:{
					required:true,
					minlength:4,
					maxlength:16
				},
				password:{
					required:true,
				},
				password2:{
					required:true,
					equalTo: "#password"
				},
				sex:{
					required:true,
				},
				phone:{
					required:true,
					isPhone:true,
				},
				email:{
					required:true,
					email:true,
				},
				adminRole:{
					required:true,
				},
				name:{
					required:true,
					minlength:2,
					maxlength:16
				},
				capital:{
					required:true,
					minlength:2,
					maxlength:16
				},
				age:{
					required:true,
					minlength:1,
					maxlength:16,
					digits:true
				},
			},
			onkeyup:false,
			focusCleanup:true,
			success:"valid",
			submitHandler:function(form){
				$(form).ajaxSubmit({
					type: 'post',
					url: "${rootPath}/back/AdminsBackServlet?method=adminsUpdateSubmit" ,
					/* 将service层返回的json取出来,也就是data */
					success: function(data){
						layer.msg(data.info,
						{
							icon:1,
							time:2000
						},
						function()
						{
							var index = parent.layer.getFrameIndex(window.name);
							parent.$('.btn-refresh').click();
							parent.$('.btn-success').click();
							parent.layer.close(index);
						});
					},
	                error: function(XmlHttpRequest, textStatus, errorThrown){
						layer.msg('error!',{icon:1,time:1000});
					},
					"dataType":"json"
				});				
			}
		});
	});
	</script> 
	<!--/请在上方写此页面业务相关的脚本-->
	</body>
</html>